|
|
 |
|
|
|
|
Set oRS = New Recordset
oRS.Open strSQL, ConnectString(), _
adOpenForwardOnly, adLockReadOnly
oRS.Close
Exit Sub
Error_EH: Call ErrorHandler(oRS.ActiveConnection)
Exit Sub
End Sub |
|
|
|
|
|
|
|
|
Figure 24.1 shows some sample output from this error-handling routine when you use the SQL Server OLE DB provider. Notice the description and the source properties. |
|
|
|
|
|
|
|
|
Figure 24.1
Example of an error. |
|
|
|
|
|
|
|
|
A Command object is a holder for a specific query that you want to execute against a data source. You can predefine the SQL and any parameters for that SQL, and then replace the parameters at runtime to execute the same SQL statement over and over again without having to redo the SQL statement each time. |
|
|
|
|
|
|
|
|
Reasons to Use a Command Object |
|
|
|
|
|
|
|
|
Heres a list of reasons why you would want to use a Command object: |
|
|
|
|
|
|
|
|
You can pass in parameters and receive output parameters from a stored procedure. |
|
|
|
|
|
|
|
|
You can reexecute the query with just an Execute command. |
|
|
|
|
|